home *** CD-ROM | disk | FTP | other *** search
/ Workplace Effectiveness: Critical Thinking Skills / Workplace Effectiveness: Critical Thinking Skills.iso / pc / Files / Define.dxr / 00004_drag-drop code.ls < prev    next >
Encoding:
Text File  |  1998-09-15  |  4.4 KB  |  153 lines

  1. global gMasterData, gDragSprites, gOutsideLocs, gInsideLocs, gBoardScore
  2.  
  3. on initDragData
  4.   set gDragSprites to [#firstSp: 4, #lastSp: 38, #moverSp: 48]
  5.   set gOutsideLocs to [:]
  6.   sort(gOutsideLocs)
  7.   set gInsideLocs to [:]
  8.   sort(gInsideLocs)
  9.   set gBoardScore to 0
  10.   getSpriteLocs()
  11. end
  12.  
  13. on getSpriteLocs
  14.   repeat with snum = the firstSp of gDragSprites to the lastSp of gDragSprites
  15.     addProp(gOutsideLocs, snum, point(the locH of sprite snum, the locV of sprite snum))
  16.   end repeat
  17. end
  18.  
  19. on moveItem
  20.   set xsprite to the clickOn
  21.   set moveMember to the member of sprite xsprite
  22.   set offsetH to the locH of sprite xsprite - the mouseH
  23.   set offsetV to the locV of sprite xsprite - the mouseV
  24.   set the member of sprite the moverSp of gDragSprites to moveMember
  25.   set the loc of sprite xsprite to point(-999, -999)
  26.   repeat while the mouseDown
  27.     set the loc of sprite the moverSp of gDragSprites to point(the mouseH + offsetH, the mouseV + offsetV)
  28.     updateStage()
  29.   end repeat
  30.   EvalTarget(xsprite)
  31. end
  32.  
  33. on EvalTarget xsprite
  34.   if sprite the moverSp of gDragSprites within 3 then
  35.     setInside(xsprite)
  36.   else
  37.     setOutside(xsprite)
  38.   end if
  39. end
  40.  
  41. on newLocation xsprite
  42. end
  43.  
  44. on setInside xsprite
  45.   puppetSound("thingset")
  46.   set offsetH to the locH of sprite the moverSp of gDragSprites - the mouseH
  47.   set offsetV to the locV of sprite the moverSp of gDragSprites - the mouseV
  48.   set vNewPoint to point(the mouseH + offsetH, the mouseV + offsetV)
  49.   set the loc of sprite xsprite to vNewPoint
  50.   set the loc of sprite the moverSp of gDragSprites to point(-999, -999)
  51.   setaProp(gInsideLocs, xsprite, the loc of sprite xsprite)
  52.   if getaProp(gOutsideLocs, xsprite) <> VOID then
  53.     deleteProp(gOutsideLocs, xsprite)
  54.   end if
  55. end
  56.  
  57. on setOutside xsprite
  58.   if inside(the loc of sprite the moverSp of gDragSprites, the rect of sprite 1) then
  59.     puppetSound("thingset")
  60.     set offsetH to the locH of sprite the moverSp of gDragSprites - the mouseH
  61.     set offsetV to the locV of sprite the moverSp of gDragSprites - the mouseV
  62.     set vNewPoint to point(the mouseH + offsetH, the mouseV + offsetV)
  63.     set the loc of sprite xsprite to vNewPoint
  64.     set the loc of sprite the moverSp of gDragSprites to point(-999, -999)
  65.   else
  66.     puppetSound("swoosh")
  67.     set vOrigLoc to getaProp(gOutsideLocs, xsprite)
  68.     set the loc of sprite xsprite to vOrigLoc
  69.     set the loc of sprite the moverSp of gDragSprites to point(-999, -999)
  70.   end if
  71.   setaProp(gOutsideLocs, xsprite, the loc of sprite xsprite)
  72.   if getaProp(gInsideLocs, xsprite) <> VOID then
  73.     deleteProp(gInsideLocs, xsprite)
  74.   end if
  75. end
  76.  
  77. on scoreCard scoreMode, xsprite
  78.   set vFirstOne to the firstSp of gDragSprites
  79.   case xsprite of
  80.     vFirstOne:
  81.       set thisScore to 5
  82.     (vFirstOne + 1):
  83.       set thisScore to 10
  84.     (vFirstOne + 2):
  85.       set thisScore to 5
  86.     (vFirstOne + 3):
  87.       set thisScore to -10
  88.     (vFirstOne + 4):
  89.       set thisScore to 10
  90.     (vFirstOne + 5):
  91.       set thisScore to -10
  92.     (vFirstOne + 6):
  93.       set thisScore to 10
  94.     (vFirstOne + 7):
  95.       set thisScore to 0
  96.     (vFirstOne + 8):
  97.       set thisScore to -10
  98.     (vFirstOne + 9):
  99.       set thisScore to -10
  100.     (vFirstOne + 10):
  101.       set thisScore to 0
  102.     (vFirstOne + 11):
  103.       set thisScore to 10
  104.     (vFirstOne + 12):
  105.       set thisScore to 10
  106.     (vFirstOne + 13):
  107.       set thisScore to 10
  108.     (vFirstOne + 14):
  109.       set thisScore to 0
  110.     (vFirstOne + 15):
  111.       set thisScore to 0
  112.     (vFirstOne + 16):
  113.       set thisScore to 10
  114.     (vFirstOne + 17):
  115.       set thisScore to 0
  116.     (vFirstOne + 18):
  117.       set thisScore to -5
  118.     (vFirstOne + 19):
  119.       set thisScore to 10
  120.     (vFirstOne + 20):
  121.       set thisScore to -10
  122.     (vFirstOne + 21):
  123.       set thisScore to -10
  124.     (vFirstOne + 22):
  125.       set thisScore to 0
  126.     (vFirstOne + 23):
  127.       set thisScore to -10
  128.     (vFirstOne + 24):
  129.       set thisScore to -10
  130.     (vFirstOne + 25):
  131.       set thisScore to 10
  132.     otherwise:
  133.       set thisScore to 0
  134.   end case
  135.   case scoreMode of
  136.     #add:
  137.       set gBoardScore to gBoardScore + thisScore
  138.     #subtract:
  139.       set gBoardScore to gBoardScore - thisScore
  140.   end case
  141. end
  142.  
  143. on resetItems
  144.   repeat with x = 1 to count(gInsideLocs)
  145.     set vSprite to getPropAt(gInsideLocs, x)
  146.     set the loc of sprite vSprite to getProp(gInsideLocs, vSprite)
  147.   end repeat
  148.   repeat with x = 1 to count(gOutsideLocs)
  149.     set vSprite to getPropAt(gOutsideLocs, x)
  150.     set the loc of sprite vSprite to getProp(gOutsideLocs, vSprite)
  151.   end repeat
  152. end
  153.